import { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { getChannelList } from '../store/action/channel'

export default function Channel() {
  const dispatch = useDispatch()
  useEffect(() => {
    // 发送请求把数据存储到 Redux
    dispatch(getChannelList())
  }, [dispatch])
  // !从 Redux 里面获取数据
  const channels = useSelector((state) => state.channel)
  return (
    <ul className='catagtory'>
      {channels.map((item) => (
        <li key={item.id} className='select'>
          {item.name}
        </li>
      ))}
    </ul>
  )
}
